//
//  NSString+ParseQueryString.m
//  MokoAPP
//
//  Created by 현식 강 on 11. 8. 17..
//  Copyright 2011 아이온. All rights reserved.
//

#import "NSString+ParseQueryString.h"
@implementation NSString (NSString_ParseQueryString)
-(NSDictionary *)parseQueryString {
    NSMutableDictionary *dict = [[[NSMutableDictionary alloc] initWithCapacity:6] autorelease];
    NSArray *pairs = [[[self componentsSeparatedByString:@"?"] objectAtIndex:1]  componentsSeparatedByString:@"&"];
    
    for (NSString *pair in pairs) {
        NSArray *elements = [pair componentsSeparatedByString:@"="];
        NSString *key = [[elements objectAtIndex:0] stringByReplacingPercentEscapesUsingEncoding:CFStringConvertEncodingToNSStringEncoding(0x422)];
        NSString *val = [[elements objectAtIndex:1] stringByReplacingPercentEscapesUsingEncoding:CFStringConvertEncodingToNSStringEncoding(0x422)];
        
        [dict setObject:val forKey:key];
    }
    return dict;
}
@end
